/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.inspur.edp.lcm.metadata.api.entity;

import com.inspur.edp.lcm.metadata.api.entity.MetadataDto;
import com.inspur.edp.lcm.metadata.api.entity.metadataindex.MetadataIndexRepoItemDto;
import lombok.Data;

import java.util.List;
import java.util.Objects;

/**
 * Classname MetadataIndexItemDto
 * Description 元数据索引
 * Date 2019/11/26 11:19
 *
 * @author zhongchq
 * @version 1.0
 */
@Data
public class MetadataIndexItemDto extends MetadataDto {
    //元数据所在元数据包名
    private String mdPkgName;
    private List<MetadataIndexRepoItemDto> repoPkg;

    public MetadataIndexItemDto() {
    }

    public MetadataIndexItemDto(Metadata4Ref metadata4Ref) {

        this.setId(metadata4Ref.getMetadata().getHeader().getId());
        this.setCode(metadata4Ref.getMetadata().getHeader().getCode());
        this.setName(metadata4Ref.getMetadata().getHeader().getName());
        this.setNameSpace(metadata4Ref.getMetadata().getHeader().getNameSpace());
        this.setType(metadata4Ref.getMetadata().getHeader().getType());
        this.setBizobjectID(metadata4Ref.getMetadata().getHeader().getBizobjectID());
        this.setLanguage(metadata4Ref.getMetadata().getHeader().getLanguage());
        this.setIsTranslating(metadata4Ref.getMetadata().getHeader().isTranslating());
        this.setFileName(metadata4Ref.getMetadata().getHeader().getFileName());
        this.setRelativePath(metadata4Ref.getMetadata().getRelativePath());
        if (Objects.nonNull(metadata4Ref.getPackageHeader())) {
            this.setMdPkgName(metadata4Ref.getPackageHeader().getName());
            if (!Objects.isNull(metadata4Ref.getPackageHeader().getProcessMode())) {
                this.setProcessMode(metadata4Ref.getPackageHeader().getProcessMode().toString());
            }
        }
    }
}
